package com.leejw.tradeblogsystem.service.impl;

import com.leejw.tradeblogsystem.common.ExcelUtil;
import com.leejw.tradeblogsystem.mapper.TradeMapper;
import com.leejw.tradeblogsystem.model.Shares;
import com.leejw.tradeblogsystem.model.ZTShares;
import com.leejw.tradeblogsystem.service.TradeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * @author: jwli3
 * @Desc:
 * @create: 2024-08-16
 **/
@Service
public class TradeServiceImpl implements TradeService {
    @Autowired
    private TradeMapper tradeMapper;
    @Override
    public List<ZTShares> getAll() {
        return tradeMapper.getAll();
    }

    @Override
    public Integer importExcel(MultipartFile excelFile, ZTShares ztShares) throws Exception {
        List<ZTShares>list = (List<ZTShares>) ExcelUtil.importExcel(excelFile, ztShares);
        return tradeMapper.importBatchZTShares(list);
    }

    @Override
    public List<Shares> queryAllShares() {
        return tradeMapper.getAllShares();
    }

    @Override
    public Integer importShareExcel(MultipartFile excelFile, Shares shares) throws Exception {
        List<Shares>list = ExcelUtil.importExcel(excelFile,shares);
        return tradeMapper.importBatchShares(list);
    }

    @Override
    public Shares getById(Long id) {
        return tradeMapper.getById(id);
    }

    @Override
    public void updateById(Shares shareVO) {
        tradeMapper.updateById(shareVO);
    }


}
